﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System;

namespace Fulcrum
{
    public class FulcrumSettings : ISettings
    {
        string module;

        public FulcrumSettings()
        {
            // nothing
        }

        [Setting("output", Description="The output directory for the file.")]
        public string OutputDirectory
        {
            get;
            set;
        }

        [Setting(Description = "The generation module to use.")]
        public string Module
        {
            get
            {
                return this.module;
            }

            set
            {
                this.module = value;
                OnModuleChanged();
            }
        }

        public event EventHandler ModuleChanged;

        private void OnModuleChanged()
        {
            var eh = this.ModuleChanged;

            if (eh != null)
            {
                eh(this, EventArgs.Empty);
            }
        }

        public void ValidateSettings()
        {
            if (String.IsNullOrEmpty(this.OutputDirectory))
            {
                throw new ApplicationException("An output directory MUST be specified.");
            }

            if (String.IsNullOrEmpty(this.Module))
            {
                throw new ApplicationException("An module MUST be specified.");
            }
        }
    }
}
